<?php

/**
 * 首页数据
 */

namespace app\api\controller;

use app\api\model\Banner as BannerModel;
use app\api\model\MapStrategy;
use app\api\model\Notice as NoticeModel;
use app\api\model\Metro as MetroModel;
use app\common\controller\ApiController;
use think\Db;
use think\Exception;

class Index extends ApiController {

//    protected $notNeedToken = ['index', 'test'];

    protected $notNeedPhone = ['index', 'test'];

    /**
     * 首页数据
     * @return false|string
     */
    public function index() {
        try {
            $params = $this->checkParams('');
            if ($params === false) {
                return $this->resErr();
            }
            $BannerModel = new BannerModel();
            $indexBanner = $BannerModel->getIndexBanner();//首页banner

            $NoticeModel = new NoticeModel();
            $indexNotice = $NoticeModel->noticeList();//首页头条

            $hotHouse = model('House')->hotHouse($params);//热门房源

            $hasBusinessArea = \app\api\model\BusinessArea::has_data($params);//是否有商圈

            $hasMetro = MetroModel::has_data($params);//是否有地铁

            return $this->resData('success', compact('indexBanner', 'indexNotice', 'hotHouse', 'mapStrategy', 'hasMetro', 'hasBusinessArea'));
        } catch (Exception $e) {
            return $this->resErr($e->getMessage(), $e->getCode());
        }
    }

}
